!!ARBfp1.0
#
# This shader provides subtexturing for lights....
#
#
ATTRIB iCol = fragment.color;				# Fragment color: R and G contain the tex coord offset of our light.
ATTRIB tex0 = fragment.texcoord[0];			# Tex coord 0 comes from the sprite - 0->1 as we go across the quad

OUTPUT outColor = result.color;				# Final output is a computed color.

PARAM	tex_scale	= program.local[0];		# Program local 0's X and Y contain the fraction of the tex that each light takes up.
PARAM	rgba_tinting= program.local[1];		# tint of RGB for things like sunglasses, plus a master scale for alpha

#PARAM	one 		= { 1, 1, 1, 1 };		# Constant 1.0 - used for debugging sometimes?
#PARAM 	light_soft	= program.local[3];		# This was from an experiment to change the gamma curve of lights

TEMP	texel_final_coords;					# This will be the final texture coord of the pixel
TEMP	tex_color;							# This is the color of the light from the texture
TEMP	rgba_color;							# This is the tinting needed for the final light color

# We recycled our RGB color - R and G are tex coords.  This is to work around what APPEARS to be an
# Apple bug: when point sprites are used, tex coords transfered from the vertex shader become unusable.
# (Should be fixed in 10.4.7.)  However having per-light colors is not an important feature, so we just
# splat a general tint from the shader state into the RGB colors. This gives us night-vision (all green), etc.
# For the alpha channel, we multiply by the incoming alpha which the vertex shader computes.

MOV		rgba_color, rgba_tinting;
MUL		rgba_color.w, rgba_tinting.w, iCol.w;

# Texture coordinate scaling.  Tex0 is from 0 to 1 over the sprite.  So we mult by the scale
# and add our offset to get the final tex coordinate,

MAD 	texel_final_coords, tex0, tex_scale, iCol;

# Now sample the texture

TEX 	tex_color, texel_final_coords, texture[0], 2D;

# Texture * tinting = final color.

MUL 	outColor, rgba_color, tex_color;

# If we had this in, this would effectively scale the color curve of the texture...
# we coud use this some day to make a 'foggy' effect??

#POW outColor.x, color.x, light_soft.x;
#POW outColor.y, color.y, light_soft.x;
#POW outColor.z, color.z, light_soft.x;
#POW outColor.w, color.w, light_soft.x;

#This debug code gives us a translucent white square - useful for 
#comparing the alpha and size output of the vertex shader!
#MOV	outColor, one;
#MOV outColor.w, iCol;

END
